package com.code.translate.utils;

import java.util.concurrent.ThreadLocalRandom;

/**
 * @author ggh
 * @date 2022/7/8
 */
public class RandomUtils {
    private static final char[] chars = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

    private RandomUtils() {
    }

    public static int nextInt(int bound) {
        return ThreadLocalRandom.current().nextInt(bound);
    }

    public static String nextString(int len) {
        ThreadLocalRandom random = ThreadLocalRandom.current();

        StringBuilder builder = new StringBuilder();
        int size = chars.length;
        for (int i = 0; i < len; i++) {
            builder.append(chars[random.nextInt(size)]);
        }
        return builder.toString();
    }
}
